/**
 * 窗口受理接口api
 * @author: chenyq
 * @date: 2021-01-20
 */
import request from "@/utils/request";

// 分页查询列表操作
export function page(query) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/queryStandardPages",
    method: "get",
    params: query
  });
}

// 获取事项情形信息
export function getSituationList(serviceOid) {
  return request({
    url:
      process.env.VUE_APP_SX_ROUTE_PATH +
      "/affair/sxService/getSxServiceSituationList?serviceOid=" +
      serviceOid,
    method: "get"
  });
}

// 获取用户信息
export function queryOptionTitleValStr(valueOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/detailListOptionValue/getDetailOptionTitleValStr?oid=" +
      valueOid,
    method: "get"
  });
}

// 获取事项情形信息
export function getAllSituationList(hdlOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/getSituationAndOptions?hdlOid=" +
      hdlOid,
    method: "get"
  });
}

// 获取事项情形信息
export function getSituationMaterialListByOids(serviceOid, valOidList) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materials/queryMaterialByhdlOidAndValueOids?hdlOid=" +
      serviceOid +
      "&valueOids=" +
      valOidList,
    method: "get"
  });
}

// 获取事项情形信息
export function getPreSituationMaterialListByOids(serviceOid, valOidList) {
  let optionValOids = "";
  if (valOidList != "") {
    valOidList.forEach(data => {
      optionValOids += data + ",";
    });
  }
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/materials/getPreSituationMaterialListByOids?hdlOid=" +
      serviceOid +
      "&valueOids=" +
      optionValOids,
    method: "get"
  });
}

// 获取事项情形信息
export function getSituationOpinionList(situationOid) {
  return request({
    url:
      process.env.VUE_APP_SX_ROUTE_PATH +
      "/affair/sxServiceSituationOption/getOptionTitleAndValsOfSituation?situationOid=" +
      situationOid,
    method: "get"
  });
}

// 获取事项信息（跨省通办库）
export function getSxService(serviceOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/handleDetailList/getByhdlOid?hdlOid=" +
      serviceOid,
    method: "get"
  });
}

// 获取证件类型
export function getCertificateType(type) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/common/getSelectCertificateType?type=" +
      type,
    method: "get"
  });
}

// 获取证件类型
export function changeCredentialType(oid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/basicInfomation/querySysDictByOid?dictOid=" +
      oid,
    method: "get"
  });
}

// 获取用户信息
export function getloginUser() {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/zcbl/case/getLoginInfo",
    method: "get"
  });
}

// 保存办件信息
export function saveOrUpdateKstbCase(data) {
  let titleValues = [];
  if (data.tbCaseTitleValList != "" && data.tbCaseTitleValList != undefined) {
    for (let i = 0; i < data.tbCaseTitleValList.length; i++) {
      titleValues.push(data.tbCaseTitleValList[i]);
    }
  }
  data.tbCaseTitleValList = titleValues;
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/zcbl/case/saveOrUpdateKstbCase",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=utf-8"
    },
    data: data
  });
}

// 样本材料下载方法
export function downloadAttaSimple(attaOid) {
  return request({
    url:
      process.env.VUE_APP_SX_ROUTE_PATH + "/sxSys/file/downloadFile/" + attaOid,
    method: "get"
  });
}

// 根据事项id查询材料
export function getSxMaterialByServiceOid(serviceOid) {
  return request({
    url:
      process.env.VUE_APP_SX_ROUTE_PATH +
      "/affair/serviceMaterial/getSxServiceMaterialListByServiceOid/" +
      serviceOid,
    method: "get"
  });
}
// 获取事项情形信息
export function getDetailOptionAllTitleValRelation(titleOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/detailListOptionTitle/getDetailOptionAllTitleValRelation?titleOid=" +
      titleOid,
    method: "get"
  });
}
/**
 * 查询选择区划后，指导员信息
 * @param {*} hdlOid,cityCode
 */
export function queryBusinessGuideByHdlOidAndCityCode(hdlOid, cityCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/detailListBusinessGuide/queryBusinessGuideByHdlOidAndCityCode/${hdlOid}/${cityCode}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
